package stripesbook.view;

import java.util.Collection;
import org.stripesbook.rayures.view.ViewObject;
import org.stripesbook.rayures.view.ViewTag;
import org.stripesbook.rayures.view.stripes.SErrors;
import org.stripesbook.rayures.view.stripes.SOption;
import org.stripesbook.rayures.view.stripes.SOptionsCollection;
import org.stripesbook.rayures.view.stripes.SSelect;
import org.stripesbook.rayures.view.stripes.SSubmit;
import stripesbook.model.Folder;

public class MessageAction extends ViewObject<MessageAction> {
  public MessageAction folders(Collection<Folder> folders) {
    ViewTag<?> div = tag(ViewTag.class).tagName("div").attr("id", "action");

    div.add(
      tag(SSubmit.class).name("delete"),
      bundle.get("messageList.moveToSelectedFolder"),
      tag(SSelect.class).name("selectedFolder")
        .add(tag(SOption.class).value("").label(bundle.get("messageList.selectAFolder") + "..."))
        .add(tag(SOptionsCollection.class).collection(folders).value("id").label("name")),
      tag(SSubmit.class).name("moveToFolder"),
      tag(SErrors.class).field("selectedFolder"));

    add(div);

    return getThis();
  }
}
